home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 January: Mac OS SDK / Dev.CD Jan 97 SDK2.toast / Development Kits (Disc 2) / OpenDoc Development Framework / ODFDev / ODF / Framewrk / FWSemEvt / FWDesc.cpp < prev    next >
Encoding:
Text File  |  1996-09-17  |  37.3 KB  |  1,406 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                FWDesc.cpp
  4. //    Release Version:    $ ODF 2 $
  5. //
  6. //    Copyright:    (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
  7. //
  8. //========================================================================================
  9.  
  10. #ifndef FWDESC_H
  11. #include "FWDesc.h"
  12. #endif
  13.  
  14. #ifndef FWSCPCAL_H
  15. #include "FWScpCal.h"
  16. #endif
  17.  
  18. // ----- OS Layer -----
  19.  
  20. #ifndef FWBARRAY_H
  21. #include "FWBArray.h"
  22. #endif
  23.  
  24. #ifndef FWCOLOR_H
  25. #include "FWColor.h"
  26. #endif
  27.  
  28. #ifndef FWRECT_H
  29. #include "FWRect.h"
  30. #endif
  31.  
  32. // ----- Foundation Layer -----
  33.  
  34. #ifndef FWEXCLIB_H
  35. #include "FWExcLib.h"
  36. #endif
  37.  
  38. #ifndef   FWMEMHLP_H
  39. #include "FWMemHlp.h"
  40. #endif
  41.  
  42. #ifndef   FWMEMMGR_H
  43. #include "FWMemMgr.h"
  44. #endif
  45.  
  46. #ifndef FWPSTR_H
  47. #include "FWPStr.h"
  48. #endif
  49.  
  50. #ifndef FWSOMENV_H
  51. #include "FWSOMEnv.h"
  52. #endif
  53.  
  54. // ----- Macintosh Includes -----
  55.  
  56. #ifndef __ASREGISTRY__
  57. #include <ASRegistry.h>
  58. #endif
  59.  
  60. // ----- OpenDoc Includes -----
  61.  
  62. #ifndef SOM_ODObjectSpec_xh
  63. #include <ODObjSpc.xh>
  64. #endif
  65.  
  66. //========================================================================================
  67. //    Runtime Information
  68. //========================================================================================
  69.  
  70. #ifdef FW_BUILD_MAC    
  71. #pragma segment fwsemevt2
  72. #endif
  73.  
  74. FW_DEFINE_AUTO(FW_CDesc)
  75.  
  76. //========================================================================================
  77. // CLASS FW_CDesc
  78. //========================================================================================
  79.  
  80. //----------------------------------------------------------------------------------------
  81. //    FW_CDesc::FW_CDesc
  82. //----------------------------------------------------------------------------------------
  83.  
  84. FW_CDesc::FW_CDesc() :
  85.     fOwnODDesc(TRUE),
  86.     fODDesc(NULL),
  87.     fRealPlatformDesc(TRUE),
  88.     fDataState(FW_kODDataIsStale),
  89.     fODDescType(typeWildCard),
  90.     fODDescTypeValid(FALSE)
  91. {
  92.     fPlatformDesc.descriptorType = typeNull;
  93.     fPlatformDesc.dataHandle = NULL;
  94.  
  95.     FW_END_CONSTRUCTOR
  96. }
  97.  
  98. //----------------------------------------------------------------------------------------
  99. //    FW_CDesc::FW_CDesc
  100. //----------------------------------------------------------------------------------------
  101.  
  102. FW_CDesc::FW_CDesc(const FW_CDesc& copyDesc) :
  103.     fOwnODDesc(TRUE),
  104.     fODDesc(NULL),
  105.     fRealPlatformDesc(TRUE),
  106.     fDataState(FW_kODDataIsStale),
  107.     fODDescType(typeWildCard),
  108.     fODDescTypeValid(FALSE)
  109. {
  110.     fPlatformDesc.descriptorType = typeNull;
  111.     fPlatformDesc.dataHandle = NULL;
  112.  
  113.     ::AEDuplicateDesc(copyDesc, *this);
  114.     
  115.     FW_END_CONSTRUCTOR
  116. }
  117.  
  118. //----------------------------------------------------------------------------------------
  119. //    FW_CDesc::FW_CDesc
  120. //----------------------------------------------------------------------------------------
  121.  
  122. FW_CDesc::FW_CDesc(ODDesc* odDesc) :
  123.     fOwnODDesc(FALSE),
  124.     fODDesc(odDesc),
  125.     fRealPlatformDesc(FALSE),
  126.     fDataState(FW_kPlatformDataIsStale),
  127.     fODDescType(typeWildCard),
  128.     fODDescTypeValid(FALSE)
  129. {
  130.     fPlatformDesc.descriptorType = typeNull;
  131.     fPlatformDesc.dataHandle = NULL;
  132.     
  133.     FW_END_CONSTRUCTOR
  134. }
  135.  
  136. //----------------------------------------------------------------------------------------
  137. //    FW_CDesc::~FW_CDesc
  138. //----------------------------------------------------------------------------------------
  139.  
  140. FW_CDesc::~FW_CDesc()
  141. {
  142.     FW_START_DESTRUCTOR
  143.     PrivDispose();
  144. }
  145.  
  146. //----------------------------------------------------------------------------------------
  147. //    FW_CDesc::Clear
  148. //----------------------------------------------------------------------------------------
  149.  
  150. void FW_CDesc::Clear()
  151. {
  152.     PrivFlushPlatformData();
  153. }
  154.  
  155. //----------------------------------------------------------------------------------------
  156. //    FW_CDesc::CoerceInPlace
  157. //----------------------------------------------------------------------------------------
  158.  
  159. void FW_CDesc::CoerceInPlace(ODDescType toType)
  160. {
  161.     
  162.     if (DescriptorType() != toType)
  163.         Coerce(toType, *this);
  164. }
  165.  
  166. //----------------------------------------------------------------------------------------
  167. //    FW_CDesc::Coerce
  168. //----------------------------------------------------------------------------------------
  169.  
  170. void FW_CDesc::Coerce(ODDescType toType, FW_CDesc& coercedDesc) const
  171. {
  172.     FW_Handled handled = FW_CDescCoercionCallbacks::InvokeHandler(*this, toType, coercedDesc);
  173.     
  174.     if (handled == FW_kNotHandled)
  175.         FW_FailOnError(::AECoerceDesc(*this, toType, coercedDesc));
  176. }
  177.  
  178. //----------------------------------------------------------------------------------------
  179. //    FW_CDesc::CreateSimple
  180. //----------------------------------------------------------------------------------------
  181.  
  182. void FW_CDesc::CreateSimple(ODDescType dataType, const void* dataPtr, Size dataSize)
  183. {    
  184.     FW_ASSERT(fPlatformDesc.descriptorType == typeNull);
  185.     FW_FailOnError(::AECreateDesc(dataType, dataPtr, dataSize, *this));
  186. }
  187.  
  188. //----------------------------------------------------------------------------------------
  189. //    FW_CDesc::CreateList
  190. //----------------------------------------------------------------------------------------
  191.  
  192. void FW_CDesc::CreateList(void* commonDataPtr, Size commonDataSize)
  193. {
  194.     FW_ASSERT(fPlatformDesc.descriptorType == typeNull);
  195.     FW_FailOnError(::AECreateList(commonDataPtr, commonDataSize, FALSE, *this));        
  196. }
  197.  
  198. //----------------------------------------------------------------------------------------
  199. //    FW_CDesc::CreateRecord
  200. //----------------------------------------------------------------------------------------
  201.  
  202. void FW_CDesc::CreateRecord(void* commonDataPtr, Size commonDataSize)
  203. {
  204.     FW_ASSERT(fPlatformDesc.descriptorType == typeNull);
  205.     FW_FailOnError(::AECreateList(commonDataPtr, commonDataSize, TRUE, *this));
  206. }
  207.  
  208. //----------------------------------------------------------------------------------------
  209. //    FW_CDesc::DescriptorType
  210. //----------------------------------------------------------------------------------------
  211.  
  212. ODDescType FW_CDesc::DescriptorType() const
  213. {
  214.     ODDescType descriptorType;
  215.     
  216.     if (fODDesc && fDataState == FW_kPlatformDataIsStale)
  217.     {
  218.         if (!fODDescTypeValid)
  219.         {
  220.             FW_CDesc* mutableDesc = (FW_CDesc*)this;
  221.  
  222.             FW_SOMEnvironment ev;
  223.             mutableDesc->fODDescType = fODDesc->GetDescType(ev);
  224.             mutableDesc->fODDescTypeValid = TRUE;
  225.         }
  226.         
  227.         descriptorType = fODDescType;
  228.     }
  229.     else
  230.         descriptorType = fPlatformDesc.descriptorType;
  231.     
  232.     return descriptorType;
  233. }
  234.  
  235. //----------------------------------------------------------------------------------------
  236. //    FW_CDesc::SetDescriptorType
  237. //----------------------------------------------------------------------------------------
  238.  
  239. void FW_CDesc::SetDescriptorType(ODDescType newType)
  240. {
  241.     if (fODDesc && FW_kPlatformDataIsStale)
  242.     {
  243.         FW_SOMEnvironment ev;
  244.         fODDesc->SetDescType(ev, newType);
  245.         fODDescType = newType;
  246.         fODDescTypeValid = TRUE;
  247.     }
  248.     else
  249.     {
  250.         fPlatformDesc.descriptorType = newType;
  251.         PrivPlatformDescChanged();
  252.     }
  253. }
  254.  
  255. //----------------------------------------------------------------------------------------
  256. //    FW_CDesc::PlatformDataHandle
  257. //----------------------------------------------------------------------------------------
  258.  
  259. FW_PlatformHandle FW_CDesc::PlatformDataHandle() const
  260. {
  261.     PrivUpdatePlatformDescIfStale();
  262.     return (fPlatformDesc.dataHandle);
  263. }
  264.  
  265.  
  266. //----------------------------------------------------------------------------------------
  267. //    FW_CDesc::GetDataByPtr
  268. //----------------------------------------------------------------------------------------
  269.  
  270. void FW_CDesc::GetDataByPtr(ODDescType dataType, 
  271.                             void* dataPtr, 
  272.                             Size* dataSize, 
  273.                             Size maxSize, 
  274.                             AEKeyword key) const
  275. {    
  276.     FW_CDesc     coercedDesc;
  277.     FW_Boolean    copyFromOriginal = TRUE;
  278.     
  279.     if (key == keyNoKey)
  280.     {
  281.         if (dataType != typeWildCard && DescriptorType() != dataType)
  282.         {
  283.             Coerce(dataType, coercedDesc);
  284.             copyFromOriginal = FALSE;
  285.         }
  286.     }
  287.     else
  288.     {
  289.         GetDataByDesc(coercedDesc, key);
  290.         copyFromOriginal = FALSE;
  291.     }
  292.     
  293.     FW_PlatformHandle dataHandle = copyFromOriginal ? PlatformDataHandle() 
  294.         : coercedDesc.PlatformDataHandle();
  295.     unsigned long actualSize = FW_CMemoryManager::GetSystemHandleSize(dataHandle);
  296.     
  297.     if (actualSize > maxSize)
  298.         FW_FailOnError(memFullErr);
  299.     else
  300.     {
  301.         FW_CAcquireLockedSystemHandle lock(dataHandle);
  302.         FW_CMemoryManager::CopyMemory(*dataHandle, dataPtr, actualSize);
  303.         if (dataSize)
  304.             *dataSize = actualSize;
  305.     }
  306. }
  307.  
  308. //----------------------------------------------------------------------------------------
  309. //    FW_CDesc::PutDataByPtr
  310. //----------------------------------------------------------------------------------------
  311.  
  312. void FW_CDesc::PutDataByPtr(ODDescType dataType, 
  313.                             const void* dataPtr, 
  314.                             Size dataSize, 
  315.                             AEKeyword dataKey)
  316. {    
  317.     if (dataKey == keyNoKey)
  318.     {
  319.         if (IsNullDescriptor())
  320.             CreateSimple(dataType, dataPtr, dataSize);
  321.         else
  322.         {
  323.             if (!IsList())
  324.                 CoerceInPlace(typeAEList);
  325.             FW_FailOnError(::AEPutPtr(*this, 0, dataType, dataPtr, dataSize));
  326.         }
  327.     }
  328.     else
  329.     {
  330.         if (IsNullDescriptor())
  331.             CreateRecord();
  332.         FW_FailOnError(::AEPutKeyPtr(*this, dataKey, dataType, dataPtr, dataSize));
  333.     }
  334. }
  335.  
  336. //----------------------------------------------------------------------------------------
  337. //    FW_CDesc::GetDataByDesc
  338. //----------------------------------------------------------------------------------------
  339.  
  340. void FW_CDesc::GetDataByDesc(FW_CDesc& desc,
  341.                             AEKeyword key, 
  342.                             ODDescType desiredType) const
  343. {
  344.     FW_ASSERT(desc.IsNullDescriptor());
  345.     FW_FailOnError(::AEGetKeyDesc(*this, key, desiredType, desc));
  346. }
  347.  
  348. //----------------------------------------------------------------------------------------
  349. //    FW_CDesc::PutDataByDesc
  350. //----------------------------------------------------------------------------------------
  351.  
  352. void FW_CDesc::PutDataByDesc(const FW_CDesc& desc, AEKeyword key)
  353. {
  354.     if (key == keyNoKey)
  355.     {
  356.         if (IsNullDescriptor())
  357.             *this = desc;
  358.         else
  359.         {
  360.             if (!IsList())
  361.                 CoerceInPlace(typeAEList);
  362.             PutDescIntoList(desc);
  363.         }
  364.     }
  365.     else
  366.     {
  367.         if (IsNullDescriptor())
  368.             CreateRecord();
  369.  
  370.         FW_FailOnError(::AEPutKeyDesc(*this, key, desc));
  371.     }
  372. }
  373.  
  374. //----------------------------------------------------------------------------------------
  375. //    FW_CDesc::GetItemCount
  376. //----------------------------------------------------------------------------------------
  377.  
  378. long FW_CDesc::GetItemCount() const
  379. {
  380.     long itemCount = 0;
  381.     FW_FailOnError(::AECountItems(*this, &itemCount));
  382.     
  383.     return itemCount;
  384. }
  385. //----------------------------------------------------------------------------------------
  386. //    FW_CDesc::GetDescFromList
  387. //----------------------------------------------------------------------------------------
  388.  
  389. void FW_CDesc::GetDescFromList(long index,
  390.                             FW_CDesc& retrievedDesc,
  391.                             ODDescType desiredType) const
  392. {
  393.     AEKeyword unusedKeyword;
  394.     GetDescFromList(index, unusedKeyword, retrievedDesc, desiredType);
  395. }
  396.  
  397. //----------------------------------------------------------------------------------------
  398. //    FW_CDesc::GetDescFromList
  399. //----------------------------------------------------------------------------------------
  400.  
  401. void FW_CDesc::GetDescFromList(long index,
  402.                                 AEKeyword& descKey,
  403.                                 FW_CDesc& retrievedDesc,
  404.                                 ODDescType desiredType) const
  405. {
  406.     FW_ASSERT(retrievedDesc.IsNullDescriptor());
  407.     
  408.     if (index == 1 && !IsList())
  409.     {
  410.         retrievedDesc = *this;
  411.     }
  412.     else            // Note: indexes are 1-based
  413.         FW_FailOnError(::AEGetNthDesc(*this, index, desiredType, &descKey, retrievedDesc));
  414. }
  415.  
  416. //----------------------------------------------------------------------------------------
  417. //    FW_CDesc::PutDescIntoList
  418. //----------------------------------------------------------------------------------------
  419.  
  420. void FW_CDesc::PutDescIntoList(const FW_CDesc& desc, long index)
  421. {
  422.     FW_FailOnError(::AEPutDesc(*this, index, desc));
  423. }
  424.  
  425. //----------------------------------------------------------------------------------------
  426. //    FW_CDesc::HasDataKey
  427. //----------------------------------------------------------------------------------------
  428.  
  429. FW_Boolean FW_CDesc::HasDataKey(AEKeyword key) const
  430. {
  431.     ODDescType     typeCode;
  432.     long        actualSize;
  433.     
  434.     return (::AEGetParamPtr(*this, key, typeWildCard, &typeCode, NULL, 0, &actualSize) == FW_xNoError);
  435. }
  436.  
  437. //----------------------------------------------------------------------------------------
  438. //    FW_CDesc::GetDataInfoByKey
  439. //----------------------------------------------------------------------------------------
  440.  
  441. void FW_CDesc::GetDataInfoByKey(AEKeyword key,
  442.                                 ODDescType& typeCode,
  443.                                 Size& dataSize) const
  444. {
  445.     FW_FailOnError(::AESizeOfKeyDesc(*this, key, &typeCode, &dataSize));
  446. }
  447.  
  448. //----------------------------------------------------------------------------------------
  449. //    FW_CDesc::DeleteItemByIndex
  450. //----------------------------------------------------------------------------------------
  451.  
  452. void FW_CDesc::DeleteItemByIndex(long index)
  453. {
  454.     FW_ASSERT(IsList());
  455.     
  456.     FW_FailOnError(::AEDeleteItem(*this, index));
  457. }
  458.  
  459. //----------------------------------------------------------------------------------------
  460. //    FW_CDesc::DeleteItemByKey
  461. //----------------------------------------------------------------------------------------
  462.  
  463. void FW_CDesc::DeleteItemByKey(ODDescType key)
  464. {
  465.     FW_ASSERT(IsList());
  466.     
  467.     FW_FailOnError(::AEDeleteKeyDesc(*this, key));
  468. }
  469.  
  470. //----------------------------------------------------------------------------------------
  471. //    FW_CDesc::GetEnumeratedType
  472. //----------------------------------------------------------------------------------------
  473.  
  474. ODDescType FW_CDesc::GetEnumeratedType(AEKeyword key) const
  475. {
  476.     ODDescType     value;
  477.     
  478.     GetDataByPtr(typeEnumerated, &value, NULL, sizeof(ODDescType), key);
  479.     return value;
  480. }
  481.  
  482. //----------------------------------------------------------------------------------------
  483. //    FW_CDesc::PutEnumeratedType
  484. //----------------------------------------------------------------------------------------
  485.  
  486. void FW_CDesc::PutEnumeratedType(ODDescType value, AEKeyword key)
  487. {
  488.     PutDataByPtr(typeEnumerated, &value, sizeof(ODDescType), key);
  489. }
  490. //----------------------------------------------------------------------------------------
  491. //    FW_CDesc::GetAbsoluteOrdinal
  492. //----------------------------------------------------------------------------------------
  493.  
  494. ODDescType FW_CDesc::GetAbsoluteOrdinal(AEKeyword key) const
  495. {
  496.     ODDescType     value;
  497.     
  498.     GetDataByPtr(typeAbsoluteOrdinal, &value, NULL, sizeof(ODDescType), key);
  499.     return value;
  500. }
  501.  
  502. //----------------------------------------------------------------------------------------
  503. //    FW_CDesc::PutAbsoluteOrdinal
  504. //----------------------------------------------------------------------------------------
  505.  
  506. void FW_CDesc::PutAbsoluteOrdinal(ODDescType value, AEKeyword key)
  507. {
  508.     PutDataByPtr(typeAbsoluteOrdinal, &value, sizeof(ODDescType), key);
  509. }
  510.  
  511. //----------------------------------------------------------------------------------------
  512. //    FW_CDesc::GetType
  513. //----------------------------------------------------------------------------------------
  514.  
  515. ODDescType FW_CDesc::GetType(AEKeyword key) const
  516. {
  517.     ODDescType     value;
  518.     
  519.     GetDataByPtr(typeType, &value, NULL, sizeof(ODDescType), key);
  520.     return value;
  521. }
  522.  
  523. //----------------------------------------------------------------------------------------
  524. //    FW_CDesc::PutType
  525. //----------------------------------------------------------------------------------------
  526.  
  527. void FW_CDesc::PutType(ODDescType value, AEKeyword key)
  528. {
  529.     PutDataByPtr(typeType, &value, sizeof(ODDescType), key);
  530. }
  531.  
  532. //----------------------------------------------------------------------------------------
  533. //    FW_CDesc::GetBoolean
  534. //----------------------------------------------------------------------------------------
  535.  
  536. FW_Boolean FW_CDesc::GetBoolean(AEKeyword key) const
  537. {
  538.     FW_Boolean     value;
  539.     
  540.     GetDataByPtr(typeBoolean, &value, NULL, sizeof(FW_Boolean), key);
  541.     return value;
  542. }
  543.  
  544. //----------------------------------------------------------------------------------------
  545. //    FW_CDesc::PutBoolean
  546. //----------------------------------------------------------------------------------------
  547.  
  548. void FW_CDesc::PutBoolean(FW_Boolean value, AEKeyword key)
  549. {    
  550.     PutDataByPtr(typeBoolean, &value, sizeof(FW_Boolean), key);
  551. }
  552.  
  553. //----------------------------------------------------------------------------------------
  554. //    FW_CDesc::GetLongInteger
  555. //----------------------------------------------------------------------------------------
  556.  
  557. long FW_CDesc::GetLongInteger(AEKeyword key) const
  558. {
  559.     long    value;
  560.     
  561.     GetDataByPtr(typeLongInteger, &value, NULL, sizeof(long), key);
  562.     return value;
  563. }
  564.  
  565. //----------------------------------------------------------------------------------------
  566. //    FW_CDesc::PutLongInteger
  567. //----------------------------------------------------------------------------------------
  568.  
  569. void FW_CDesc::PutLongInteger(long value, AEKeyword key)
  570. {
  571.     PutDataByPtr(typeLongInteger, &value, sizeof(long), key);
  572. }
  573.  
  574. //----------------------------------------------------------------------------------------
  575. //    FW_CDesc::GetShortInteger
  576. //----------------------------------------------------------------------------------------
  577.  
  578. short FW_CDesc::GetShortInteger(AEKeyword key) const
  579. {    
  580.     short    value;
  581.     
  582.     GetDataByPtr(typeShortInteger, &value, NULL, sizeof(short), key);
  583.     return value;
  584. }
  585.  
  586. //----------------------------------------------------------------------------------------
  587. //    FW_CDesc::GetString
  588. //----------------------------------------------------------------------------------------
  589.  
  590. void FW_CDesc::GetString(FW_CString& string, AEKeyword key) const
  591. {
  592.     FW_CDesc     secondaryDesc;
  593.     FW_Boolean    copyFromThis = TRUE;
  594.     
  595.     if (key != keyNoKey)
  596.     {
  597.         GetDataByDesc(secondaryDesc, key, typeChar);
  598.         copyFromThis = FALSE;
  599.     }
  600.     else if (DescriptorType() != typeChar)
  601.     {
  602.         Coerce(typeChar, secondaryDesc);
  603.         copyFromThis = FALSE;
  604.     }
  605.  
  606.     FW_PlatformHandle dataHandle = copyFromThis ? PlatformDataHandle() : secondaryDesc.PlatformDataHandle();
  607.     
  608.     FW_CAcquireLockedSystemHandle lock(dataHandle);
  609.     string.ReplaceAll(*dataHandle, FW_CMemoryManager::GetSystemHandleSize(dataHandle));
  610. }
  611.  
  612. //----------------------------------------------------------------------------------------
  613. //    FW_CDesc::PutString
  614. //----------------------------------------------------------------------------------------
  615.  
  616. void FW_CDesc::PutString(const FW_CString& string, AEKeyword key)
  617. {
  618.     PutDataByPtr(typeChar, string.RevealBuffer(), string.GetByteLength(), key);
  619. }
  620.  
  621. //----------------------------------------------------------------------------------------
  622. //    FW_CDesc::GetColor
  623. //----------------------------------------------------------------------------------------
  624.  
  625. void FW_CDesc::GetColor(FW_CColor& color, AEKeyword key) const
  626. {
  627.     RGBColor     platformColor;
  628.     
  629.     GetDataByPtr(typeRGBColor, &platformColor, NULL, sizeof(RGBColor), key);
  630.     color = platformColor;
  631. }
  632.  
  633. //----------------------------------------------------------------------------------------
  634. //    FW_CDesc::PutColor
  635. //----------------------------------------------------------------------------------------
  636.  
  637. void FW_CDesc::PutColor(const FW_CColor& color, AEKeyword key)
  638. {
  639.     RGBColor platformColor = color;
  640.     PutDataByPtr(typeRGBColor, &platformColor, sizeof(RGBColor), key);
  641. }
  642.  
  643. //----------------------------------------------------------------------------------------
  644. //    FW_CDesc::GetPoint
  645. //----------------------------------------------------------------------------------------
  646.  
  647. void FW_CDesc::GetPoint(FW_CPoint& point, AEKeyword key) const
  648. {
  649.     FW_PlatformPoint platformPoint;
  650.     
  651.     GetDataByPtr(typeQDPoint, &platformPoint, NULL, sizeof(FW_PlatformPoint), key);
  652.     point = platformPoint;
  653. }
  654.  
  655. //----------------------------------------------------------------------------------------
  656. //    FW_CDesc::PutPoint
  657. //----------------------------------------------------------------------------------------
  658.  
  659. void FW_CDesc::PutPoint(const FW_CPoint& point, AEKeyword key)
  660. {
  661.     FW_PlatformPoint platformPoint = point.AsPlatformPoint();
  662.  
  663.     PutDataByPtr(typeQDPoint, &platformPoint, sizeof(FW_PlatformPoint), key);
  664. }
  665.  
  666. //----------------------------------------------------------------------------------------
  667. //    FW_CDesc::GetRect
  668. //----------------------------------------------------------------------------------------
  669.  
  670. void FW_CDesc::GetRect(FW_CRect& rect, AEKeyword key) const
  671. {
  672.     FW_PlatformRect platformRect;
  673.     
  674.     GetDataByPtr(typeQDRectangle, &platformRect, NULL, sizeof(FW_PlatformRect), key);
  675.     rect = platformRect;
  676. }
  677.  
  678. //----------------------------------------------------------------------------------------
  679. //    FW_CDesc::PutRect
  680. //----------------------------------------------------------------------------------------
  681.  
  682. void FW_CDesc::PutRect(const FW_CRect& rect, AEKeyword key)
  683. {
  684.     FW_PlatformRect platformRect = rect.AsPlatformRect();
  685.     PutDataByPtr(typeQDRectangle, &platformRect, sizeof(FW_PlatformRect), key);
  686. }
  687.  
  688.  
  689. //----------------------------------------------------------------------------------------
  690. //    FW_CDesc::Compare(const FW_CDesc& other, const ODDescType operation)
  691. //----------------------------------------------------------------------------------------
  692.  
  693. FW_Boolean FW_CDesc::Compare(ODDescType operation, const FW_CDesc& other) const
  694. {
  695.     if (this == &other)    // compare to self
  696.     {
  697.         switch (operation)
  698.         {
  699.             case kAEEquals:
  700.             case kAEGreaterThanEquals:
  701.             case kAELessThanEquals:
  702.             case kAEBeginsWith:
  703.             case kAEEndsWith:
  704.             case kAEContains:
  705.                 return TRUE;
  706.                 break;
  707.                 
  708.             case kASNotEqual:
  709.             case kAEGreaterThan:
  710.             case kAELessThan:
  711.                 return FALSE;
  712.                 break;
  713.             
  714.             default:
  715.                 FW_Failure(errAEEventNotHandled);
  716.                 break;
  717.         }
  718.     }
  719.     
  720.     FW_CDesc         secondaryDesc;
  721.     const FW_CDesc*    lhDesc = this;
  722.     const FW_CDesc*    rhDesc = &other;
  723.     FW_Boolean         result = TRUE;
  724.     
  725.     if (DescriptorType() != other.DescriptorType())    // coerce to common type
  726.     {
  727.         if (AECoerceDesc(other, DescriptorType(), secondaryDesc) == noErr)
  728.             rhDesc = &secondaryDesc;
  729.         else if (AECoerceDesc(*this, other.DescriptorType(), secondaryDesc) == noErr)
  730.             lhDesc = &secondaryDesc;
  731.         else
  732.             return FALSE;
  733.     }
  734.     
  735.     if (lhDesc->IsList())
  736.     {
  737.         result = PrivCompareLists(operation, *lhDesc, *rhDesc);
  738.     }
  739.     else
  740.     {
  741.         FW_Handled handled = FW_CDescComparisonCallbacks::InvokeHandler(operation, *lhDesc, *rhDesc, result);
  742.         if (handled != FW_kHandled)
  743.         {
  744.             switch (lhDesc->DescriptorType())
  745.             {
  746.                 long lhLong;
  747.                 long rhLong;
  748.                 
  749.                 case typeEnumerated:
  750.                     lhLong = (long)lhDesc->GetEnumeratedType();
  751.                     rhLong = (long)rhDesc->GetEnumeratedType();
  752.                     result = PrivCompareLongs(operation, lhLong, rhLong);
  753.                     break;
  754.                     
  755.                 case typeType:
  756.                     lhLong = (long)lhDesc->GetType();
  757.                     rhLong = (long)rhDesc->GetType();
  758.                     result = PrivCompareLongs(operation, lhLong, rhLong);
  759.                     break;
  760.                     
  761.                 case typeBoolean:
  762.                     lhLong = (long)lhDesc->GetBoolean();
  763.                     rhLong = (long)rhDesc->GetBoolean();
  764.                     result = PrivCompareLongs(operation, lhLong, rhLong);
  765.                     break;
  766.                     
  767.                 case typeLongInteger:
  768.                 case typeShortInteger:
  769.                     lhLong = lhDesc->GetLongInteger();
  770.                     rhLong = rhDesc->GetLongInteger();
  771.                     result = PrivCompareLongs(operation, lhLong, rhLong);
  772.                     break;
  773.                     
  774.                 case typeChar:
  775.                     {
  776.                         FW_CString lhString;
  777.                         FW_CString rhString;
  778.                         lhDesc->GetString(lhString);
  779.                         rhDesc->GetString(rhString);
  780.                         result = PrivCompareStrings(operation, lhString, rhString);
  781.                     }
  782.                     break;
  783.                 
  784.                 case typeRGBColor:
  785.                     {
  786.                         FW_CColor lhColor;
  787.                         FW_CColor rhColor;
  788.                         lhDesc->GetColor(lhColor);
  789.                         rhDesc->GetColor(rhColor);
  790.                         result = PrivCompareColors(operation, lhColor, rhColor);
  791.                     }
  792.                     break;
  793.                     
  794.                 default:
  795.                     result = PrivCompareData(operation, *lhDesc, *rhDesc);
  796.                     break;
  797.             }
  798.         }
  799.     }
  800.     
  801.     return result;
  802. }
  803.  
  804. //----------------------------------------------------------------------------------------
  805. //    FW_CDesc::operator=(const FW_CDesc& other)
  806. //----------------------------------------------------------------------------------------
  807.  
  808. FW_CDesc& FW_CDesc::operator=(const FW_CDesc& other)
  809. {
  810.     if (this == &other)
  811.         return *this;
  812.     
  813.     PrivFlushData();
  814.     FW_FailOnError(::AEDuplicateDesc(other, *this));
  815.     
  816.     return (*this);
  817. }
  818.  
  819. //----------------------------------------------------------------------------------------
  820. //    AEDesc& FW_CDesc::operator const AEDesc&
  821. //----------------------------------------------------------------------------------------
  822.  
  823. FW_CDesc::operator const AEDesc&() const
  824. {
  825.     PrivUpdatePlatformDescIfStale();
  826.     return fPlatformDesc;
  827. }
  828.  
  829. //----------------------------------------------------------------------------------------
  830. //    FW_CDesc::operator AEDesc* const
  831. //----------------------------------------------------------------------------------------
  832.  
  833. FW_CDesc::operator AEDesc*() const
  834. {
  835.     PrivUpdatePlatformDescIfStale();
  836.     PrivPlatformDescChanged();    // non-const access might change data
  837.     return PrivGetPlatformDescPtr();
  838. }
  839.  
  840. //----------------------------------------------------------------------------------------
  841. //    FW_CDesc::operator const AEDesc*
  842. //----------------------------------------------------------------------------------------
  843.  
  844. FW_CDesc::operator const AEDesc*() const
  845. {
  846.     PrivUpdatePlatformDescIfStale();
  847.     return (AEDesc*)&fPlatformDesc;
  848. }
  849.  
  850. //----------------------------------------------------------------------------------------
  851. //    FW_CDesc::operator ODDesc*
  852. //----------------------------------------------------------------------------------------
  853.  
  854. FW_CDesc::operator ODDesc*() const
  855. {
  856.     PrivUpdateODDescIfStale();
  857.     PrivODDescChanged();
  858.     return fODDesc;
  859. }
  860.  
  861. //----------------------------------------------------------------------------------------
  862. //    FW_CDesc::operator ODObjectSpec*
  863. //----------------------------------------------------------------------------------------
  864.  
  865. FW_CDesc::operator ODObjectSpec*() const
  866. {
  867.     PrivUpdateODDescIfStale();
  868.     PrivODDescChanged();
  869.     return (ODObjectSpec*)fODDesc;
  870. }
  871.  
  872. //----------------------------------------------------------------------------------------
  873. //    FW_CDesc::operator ODOSLToken*
  874. //----------------------------------------------------------------------------------------
  875.  
  876. FW_CDesc::operator ODOSLToken*() const
  877. {
  878.     PrivUpdateODDescIfStale();
  879.     PrivODDescChanged();
  880.     return (ODOSLToken*)fODDesc;
  881. }
  882.  
  883. //----------------------------------------------------------------------------------------
  884. //    FW_CDesc::operator ODAddressDesc*
  885. //----------------------------------------------------------------------------------------
  886.  
  887. FW_CDesc::operator ODAddressDesc*() const
  888. {
  889.     PrivUpdateODDescIfStale();
  890.     PrivODDescChanged();
  891.     return (ODAddressDesc*)fODDesc;
  892. }
  893.  
  894. //----------------------------------------------------------------------------------------
  895. //    FW_CDesc::operator ODAddressDesc**
  896. //----------------------------------------------------------------------------------------
  897.  
  898. FW_CDesc::operator ODAddressDesc**()
  899. {
  900.     PrivDispose();
  901.     PrivODDescChanged();
  902.     return (ODAddressDesc**)&fODDesc;
  903. }
  904.  
  905. //----------------------------------------------------------------------------------------
  906. //    FW_CDesc::PrivCompareLists
  907. //----------------------------------------------------------------------------------------
  908.  
  909. FW_Boolean FW_CDesc::PrivCompareLists(ODDescType operation,
  910.                                     const FW_CDesc& lhDesc,
  911.                                     const FW_CDesc& rhDesc) const
  912. {
  913.     FW_Boolean result = TRUE;
  914.     FW_Boolean resultConclusive = FALSE;
  915.     
  916.     long     maxToCompare;
  917.     long    lhIndex = 1;
  918.     
  919.     switch(operation)
  920.     {
  921.         case kAEEquals:
  922.             maxToCompare = lhDesc.GetItemCount();
  923.             if (maxToCompare != rhDesc.GetItemCount())
  924.             {
  925.                 result = FALSE;
  926.                 resultConclusive = TRUE;
  927.             }
  928.             break;
  929.             
  930.         case kASNotEqual:
  931.             maxToCompare = lhDesc.GetItemCount();
  932.             if (maxToCompare != rhDesc.GetItemCount())
  933.             {
  934.                 result = TRUE;
  935.                 resultConclusive = TRUE;
  936.             }
  937.             break;
  938.             
  939.         case kAEBeginsWith:
  940.             maxToCompare = rhDesc.GetItemCount();
  941.             if (maxToCompare > lhDesc.GetItemCount())
  942.             {
  943.                 result = FALSE;
  944.                 resultConclusive = TRUE;
  945.             }
  946.             break;
  947.             
  948.         case kAEEndsWith:
  949.             maxToCompare = rhDesc.GetItemCount();
  950.             if (maxToCompare > lhDesc.GetItemCount())
  951.             {
  952.                 result = FALSE;
  953.                 resultConclusive = TRUE;
  954.             }
  955.             else
  956.                 lhIndex = lhDesc.GetItemCount() - maxToCompare + 1;
  957.             break;
  958.                     
  959.         default:
  960.             result = FALSE;
  961.             resultConclusive = TRUE;
  962.             break;
  963.     }
  964.     
  965.     if (!resultConclusive)
  966.     {
  967.         FW_CDesc lhTestDesc;
  968.         FW_CDesc rhTestDesc;
  969.         
  970.         for (long rhIndex = 1; rhIndex <= maxToCompare && result; lhIndex++, rhIndex++)
  971.         {
  972.             lhDesc.GetDescFromList(lhIndex, lhTestDesc);
  973.             rhDesc.GetDescFromList(rhIndex, rhTestDesc);
  974.             
  975.             result = lhTestDesc.Compare(operation, rhTestDesc);
  976.             
  977.             lhTestDesc.Clear();
  978.             rhTestDesc.Clear();
  979.         }
  980.     }
  981.     
  982.     return result;
  983. }
  984.  
  985. //----------------------------------------------------------------------------------------
  986. //    FW_CDesc::PrivCompareLongs
  987. //----------------------------------------------------------------------------------------
  988.  
  989. FW_Boolean FW_CDesc::PrivCompareLongs(ODDescType operation, 
  990.                                     long lhs, 
  991.                                     long rhs) const
  992. {
  993.     FW_Boolean result;
  994.     
  995.     switch (operation)
  996.     {
  997.         case kAEEquals:
  998.             result = (lhs == rhs);
  999.             break;
  1000.             
  1001.         case kASNotEqual:
  1002.             result = (lhs != rhs);
  1003.             break;
  1004.             
  1005.         case kAEGreaterThanEquals:
  1006.             result = (lhs >= rhs);
  1007.             break;
  1008.         
  1009.         case kAEGreaterThan:
  1010.             result = (lhs > rhs);
  1011.             break;
  1012.             
  1013.         case kAELessThanEquals:
  1014.             result = (lhs <= rhs);
  1015.             break;
  1016.             
  1017.         case kAELessThan:
  1018.             result = (lhs < rhs);
  1019.             break;
  1020.             
  1021.         default:
  1022.             FW_Failure(errAEEventNotHandled);
  1023.             break;
  1024.     }
  1025.     
  1026.     return result;
  1027. }
  1028.  
  1029. //----------------------------------------------------------------------------------------
  1030. //    FW_CDesc::PrivCompareStrings
  1031. //----------------------------------------------------------------------------------------
  1032.  
  1033. FW_Boolean FW_CDesc::PrivCompareStrings(ODDescType operation,
  1034.                                         const FW_CString& lhs, 
  1035.                                         const FW_CString& rhs) const
  1036. {
  1037.     FW_Boolean result;
  1038.     
  1039.     switch (operation)
  1040.     {
  1041.         FW_BytePosition    foundPosition;
  1042.         
  1043.         case kAEEquals:
  1044.             result = (lhs == rhs);
  1045.             break;
  1046.             
  1047.         case kASNotEqual:
  1048.             result = (lhs != rhs);
  1049.             break;
  1050.             
  1051.         case kAEGreaterThan:
  1052.             result = (lhs > rhs);
  1053.             break;
  1054.             
  1055.         case kAEGreaterThanEquals:
  1056.             result = (lhs >= rhs);
  1057.             break;
  1058.             
  1059.         case kAELessThan:
  1060.             result = (lhs < rhs);
  1061.             break;
  1062.             
  1063.         case kAELessThanEquals:
  1064.             result = (lhs <= rhs);
  1065.             break;
  1066.             
  1067.         case kAEBeginsWith:
  1068.             lhs.FindSubString(rhs, foundPosition);
  1069.             result = (foundPosition == 1);
  1070.             break;
  1071.             
  1072.         case kAEEndsWith:
  1073.             lhs.FindSubString(rhs, foundPosition);
  1074.             result = ((foundPosition > 0) && 
  1075.                 (foundPosition == (lhs.GetByteLength() - rhs.GetByteLength())));
  1076.             break;
  1077.             
  1078.         case kAEContains:
  1079.             lhs.FindSubString(rhs, foundPosition);
  1080.             result = (foundPosition > 0);
  1081.             break;
  1082.                                                 
  1083.         default:
  1084.             FW_Failure(errAEEventNotHandled);
  1085.             break;
  1086.     }
  1087.     
  1088.     return result;
  1089. }
  1090.  
  1091. //----------------------------------------------------------------------------------------
  1092. //    FW_CDesc::PrivCompareColors
  1093. //----------------------------------------------------------------------------------------
  1094.  
  1095. FW_Boolean FW_CDesc::PrivCompareColors(ODDescType operation,
  1096.                                     const FW_CColor& lhs, 
  1097.                                     const FW_CColor& rhs) const
  1098. {
  1099.     FW_Boolean result;
  1100.     
  1101.     switch (operation)
  1102.     {
  1103.         case kAEEquals:
  1104.             result = (lhs == rhs);
  1105.             break;
  1106.             
  1107.         case kASNotEqual:
  1108.             result = (lhs != rhs);
  1109.             break;
  1110.             
  1111.         case kAEGreaterThan:
  1112.             result = lhs.IsLighterThan(rhs);
  1113.             break;
  1114.             
  1115.         case kAEGreaterThanEquals:
  1116.             result = (lhs == rhs || lhs.IsLighterThan(rhs));
  1117.             break;
  1118.             
  1119.         case kAELessThan:
  1120.             result = lhs.IsDarkerThan(rhs);
  1121.             break;
  1122.             
  1123.         case kAELessThanEquals:
  1124.             result = (lhs == rhs || lhs.IsDarkerThan(rhs));
  1125.             break;
  1126.  
  1127.         default:
  1128.             FW_Failure(errAEEventNotHandled);
  1129.             break;
  1130.     }
  1131.     return result;
  1132. }
  1133. //----------------------------------------------------------------------------------------
  1134. //    FW_CDesc::PrivCompareData
  1135. //----------------------------------------------------------------------------------------
  1136.  
  1137. FW_Boolean FW_CDesc::PrivCompareData(ODDescType operation,
  1138.                                     const FW_CDesc& lhDesc,
  1139.                                     const FW_CDesc& rhDesc) const
  1140. {
  1141.     
  1142.     long lhDataSize = FW_CMemoryManager::GetSystemHandleSize(lhDesc.PlatformDataHandle());
  1143.     long rhDataSize = FW_CMemoryManager::GetSystemHandleSize(rhDesc.PlatformDataHandle());
  1144.  
  1145.     FW_CAcquireLockedSystemHandle lhLock(lhDesc.PlatformDataHandle());
  1146.     FW_CAcquireLockedSystemHandle rhLock(rhDesc.PlatformDataHandle());
  1147.  
  1148.     const char* lhData = *lhDesc.PlatformDataHandle();
  1149.     const char* rhData = *rhDesc.PlatformDataHandle();
  1150.  
  1151.     long bytesToCompare;
  1152.  
  1153.     FW_Boolean result = TRUE;
  1154.     FW_Boolean resultConclusive = FALSE;
  1155.  
  1156.     switch (operation)
  1157.     {
  1158.         case kAEEquals:
  1159.             bytesToCompare = lhDataSize;
  1160.             if (bytesToCompare != rhDataSize)
  1161.             {
  1162.                 result = FALSE;
  1163.                 resultConclusive = TRUE;
  1164.             }
  1165.             break;
  1166.             
  1167.         case kASNotEqual:
  1168.             bytesToCompare = lhDataSize;
  1169.             if (bytesToCompare != rhDataSize)
  1170.             {
  1171.                 result = TRUE;
  1172.                 resultConclusive = TRUE;
  1173.             }
  1174.             break;
  1175.             
  1176.         case kAEBeginsWith:
  1177.             bytesToCompare = rhDataSize;
  1178.             if (bytesToCompare > lhDataSize)
  1179.             {
  1180.                 result = FALSE;
  1181.                 resultConclusive = TRUE;
  1182.             }
  1183.             break;
  1184.             
  1185.         case kAEEndsWith:
  1186.             bytesToCompare = rhDataSize;
  1187.             if (bytesToCompare > lhDataSize)
  1188.             {
  1189.                 result = FALSE;
  1190.                 resultConclusive = TRUE;
  1191.             }
  1192.             else
  1193.                 lhData = (*lhDesc.PlatformDataHandle()) + lhDataSize - bytesToCompare;
  1194.             break;
  1195.             
  1196.         default:
  1197.             result = FALSE;
  1198.             resultConclusive = FALSE;
  1199.             break;
  1200.     }
  1201.         
  1202.     while (bytesToCompare && !resultConclusive)
  1203.     {
  1204.         switch (operation)
  1205.         {
  1206.             case kAEEquals:
  1207.             case kAEBeginsWith:
  1208.             case kAEEndsWith:
  1209.                 result = (*lhData == *rhData);
  1210.                 if (!result)
  1211.                     resultConclusive = TRUE;
  1212.                 break;
  1213.             
  1214.             case kASNotEqual:
  1215.                 result = (*lhData != *rhData);
  1216.                 if (result)
  1217.                     resultConclusive = TRUE;
  1218.                 break;
  1219.                 
  1220.             case kAEGreaterThan:
  1221.                 result = *lhData > *rhData;
  1222.                 if (!result)
  1223.                     resultConclusive = TRUE;
  1224.                 break;
  1225.                 
  1226.             case kAEGreaterThanEquals:
  1227.                 result = *lhData >= *rhData;
  1228.                 if (!result)
  1229.                     resultConclusive = TRUE;
  1230.                 break;
  1231.                 
  1232.             case kAELessThan:
  1233.                 result = *lhData < *rhData;
  1234.                 if (!result)
  1235.                     resultConclusive = TRUE;
  1236.                 break;
  1237.                 
  1238.             case kAELessThanEquals:
  1239.                 result = *lhData <= *rhData;
  1240.                 if (!result)
  1241.                     resultConclusive = TRUE;
  1242.                 break;
  1243.             
  1244.             default:
  1245.                 result = FALSE;
  1246.                 resultConclusive = TRUE;
  1247.         }
  1248.         
  1249.         lhData++;
  1250.         rhData++;
  1251.         bytesToCompare--;
  1252.     }
  1253.     return result;
  1254. }
  1255.  
  1256. //----------------------------------------------------------------------------------------
  1257. //    FW_CDesc::PrivFlushPlatformData
  1258. //----------------------------------------------------------------------------------------
  1259.  
  1260. void FW_CDesc::PrivFlushPlatformData() const
  1261. {
  1262.     FW_CDesc& mutableDesc = (FW_CDesc&)*this;
  1263.     
  1264.     if (fPlatformDesc.dataHandle != NULL)
  1265.     {
  1266.         if (fRealPlatformDesc)
  1267.             ::AEDisposeDesc(&mutableDesc.fPlatformDesc);
  1268.         else
  1269.         {
  1270.             ::DisposeHandle(fPlatformDesc.dataHandle);
  1271.             mutableDesc.fPlatformDesc.dataHandle = NULL;
  1272.         }
  1273.     }
  1274.  
  1275.     mutableDesc.fPlatformDesc.descriptorType = typeNull;
  1276.     mutableDesc.fDataState = FW_kODDataIsStale;
  1277. }
  1278.  
  1279. //----------------------------------------------------------------------------------------
  1280. //    FW_CDesc::PrivFlushODData
  1281. //----------------------------------------------------------------------------------------
  1282.  
  1283. void FW_CDesc::PrivFlushODData() const
  1284. {
  1285.     if (fODDesc)
  1286.     {
  1287.         FW_CByteArray        byteArray;
  1288.         FW_SOMEnvironment    ev;                
  1289.         
  1290.         byteArray.Set(NULL, 0);
  1291.         fODDesc->SetRawData(ev, byteArray);
  1292.         fODDesc->SetDescType(ev, typeNull);
  1293.     }
  1294. }
  1295.  
  1296. //----------------------------------------------------------------------------------------
  1297. //    FW_CDesc::PrivFlushData
  1298. //----------------------------------------------------------------------------------------
  1299.  
  1300. void FW_CDesc::PrivFlushData()
  1301. {
  1302.     PrivFlushPlatformData();
  1303.     PrivFlushODData();
  1304.         
  1305.     fDataState = FW_kPlatformMatchesOD;
  1306. }
  1307.  
  1308. //----------------------------------------------------------------------------------------
  1309. //    FW_CDesc::PrivDispose
  1310. //----------------------------------------------------------------------------------------
  1311.  
  1312. void FW_CDesc::PrivDispose()
  1313. {
  1314.     if (fODDesc)
  1315.     {
  1316.         if (fOwnODDesc)
  1317.             delete fODDesc;
  1318.         else
  1319.             PrivUpdateODDescIfStale();
  1320.         
  1321.         fODDesc = NULL;
  1322.         fOwnODDesc = TRUE;
  1323.     }
  1324.     
  1325.     fDataState = FW_kPlatformMatchesOD;
  1326.  
  1327.     PrivFlushPlatformData();
  1328.     
  1329. }
  1330.  
  1331. //----------------------------------------------------------------------------------------
  1332. //    FW_CDesc::PrivUpdatePlatformDesc
  1333. //----------------------------------------------------------------------------------------
  1334.  
  1335. void FW_CDesc::PrivUpdatePlatformDesc() const
  1336. {
  1337.     FW_ASSERT(fODDesc);
  1338.     
  1339.     FW_CDesc*            mutableDesc = (FW_CDesc*)this;
  1340.     FW_SOMEnvironment    ev;
  1341.     ODDescType            odDescType = fODDesc->GetDescType(ev);
  1342.     
  1343.     mutableDesc->fDataState = FW_kSynchronizing;
  1344.  
  1345.     PrivFlushPlatformData();
  1346.         
  1347.     if (odDescType != typeNull)
  1348.     {
  1349.         ODByteArray byteArray;
  1350.         byteArray = fODDesc->GetRawData(ev); 
  1351.             // use a temporary type to prevent redundant list/record
  1352.             // header info from being generated when AECreateDesc is called
  1353.         mutableDesc->CreateSimple('greg', byteArray._buffer, byteArray._length);
  1354.         mutableDesc->fPlatformDesc.descriptorType = odDescType;
  1355.     }
  1356.     
  1357.     mutableDesc->fDataState = FW_kPlatformMatchesOD;
  1358. }
  1359.  
  1360. //----------------------------------------------------------------------------------------
  1361. //    FW_CDesc::PrivUpdateODDesc
  1362. //----------------------------------------------------------------------------------------
  1363.  
  1364. void FW_CDesc::PrivUpdateODDesc() const
  1365. {
  1366.     
  1367.     FW_CByteArray        byteArray;
  1368.     FW_CDesc*            mutableDesc = (FW_CDesc*)this;
  1369.     FW_SOMEnvironment    ev;                
  1370.  
  1371.     mutableDesc->fDataState = FW_kSynchronizing;
  1372.     
  1373.     PrivFlushODData();
  1374.     
  1375.     if (!fODDesc)
  1376.         mutableDesc->fODDesc = PrivCreateODDesc(ev);
  1377.     
  1378.     if (fPlatformDesc.descriptorType != typeNull)
  1379.         fODDesc->SetDescType(ev, fPlatformDesc.descriptorType);
  1380.             
  1381.     if (fPlatformDesc.dataHandle != NULL)
  1382.     {
  1383.         FW_CAcquireLockedSystemHandle lock(fPlatformDesc.dataHandle);
  1384.         byteArray.Set(*fPlatformDesc.dataHandle, FW_CMemoryManager::GetSystemHandleSize(fPlatformDesc.dataHandle));
  1385.         fODDesc->SetRawData(ev, byteArray);
  1386.     }
  1387.     else
  1388.         fODDesc->SetRawData(ev, byteArray);
  1389.     
  1390.     mutableDesc->fODDescType = fPlatformDesc.descriptorType;
  1391.     mutableDesc->fODDescTypeValid = TRUE;
  1392.     mutableDesc->fDataState = FW_kPlatformMatchesOD;
  1393. }
  1394.  
  1395. //----------------------------------------------------------------------------------------
  1396. //    FW_CDesc::PrivCreateODDesc
  1397. //----------------------------------------------------------------------------------------
  1398.  
  1399. ODDesc* FW_CDesc::PrivCreateODDesc(Environment* ev) const
  1400. {    
  1401.     ODDesc* odDesc = new ODDesc;
  1402.     odDesc->InitODDesc(ev);
  1403.     
  1404.     return odDesc;
  1405. }
  1406.